package com.huo.thread.synchronizeddemo;

import java.util.concurrent.atomic.AtomicInteger;

public class DeadDemo extends  Thread{
    private Object object1;
    private Object object2;
    public DeadDemo(Object object1,Object object2) {
        this.object1 = object1;
        this.object2 = object2;
    }

    public void run(){
        synchronized(object1){
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (object2){
                System.out.println("test");
            }
        }
    }

    public static void main(String[] args) {
        Object object1 = new Object();
        Object object2 = new Object();
        new DeadDemo(object1,object2).start();
        new DeadDemo(object2,object1).start();
    }
}
